package xcmg.device.web.order;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import xcmg.device.infra.BasicController;
import xcmg.device.service.order.GpsMmJisoPoHeadService;
import xcmg.device.service.vo.order.GpsMmJisoPoHeadVO;
import yb.ecp.fast.infra.annotation.FastMappingInfo;
import yb.ecp.fast.infra.infra.ActionResult;
import yb.ecp.fast.infra.infra.PageCommonVO;
import yb.ecp.fast.infra.infra.SearchCommonVO;


/**
 * GPS同步订单实现类
 */
@RestController
@RequestMapping("/gpsMmJisoPoHead")
@Api(tags = "GPS同步订单")
@Slf4j
public class GpsMmJisoPoHeadController extends BasicController {
    @Autowired
    private GpsMmJisoPoHeadService gpsMmJisoPoHeadService;

    @RequestMapping(value = "/page", method = RequestMethod.POST)
    @FastMappingInfo(needLogin = true)
    public ActionResult<PageInfo<GpsMmJisoPoHeadVO>> page(@RequestBody SearchCommonVO<GpsMmJisoPoHeadVO> condition) throws Exception {
        GpsMmJisoPoHeadVO gpsMmSwOrderVO = condition.getFilters();
        if (gpsMmSwOrderVO == null) {
            gpsMmSwOrderVO = new GpsMmJisoPoHeadVO();
        }
        if (gpsMmSwOrderVO.getDownOrgId() == null) {
            gpsMmSwOrderVO.setDownOrgId(getOrgId());
        }
        condition.setFilters(gpsMmSwOrderVO);
        PageCommonVO<GpsMmJisoPoHeadVO> pageCommonVO = gpsMmJisoPoHeadService.list(condition);
        return actionValueResult(pageCommonVO.getPageInfo());
    }

    @RequestMapping(value = "/item", method = RequestMethod.GET)
    @FastMappingInfo(needLogin = true)
    public ActionResult<GpsMmJisoPoHeadVO> item(Long id) throws Exception {
        String orgId = getOrgId();
        return actionValueResult(gpsMmJisoPoHeadService.getVoById(id, orgId));
    }
}
